package com.example.book.in.service;

import com.example.book.base.BaseService;
import com.example.book.in.entity.BookPopularity;
import com.example.book.in.dao.BookPopularityDao;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hcj
 * @date 2019-12-10 16:02:03
 */
@Service
public class BookPopularityService extends BaseService<BookPopularity, BookPopularityDao> {

    public List<BookPopularity> findFrontList(Integer limit) {
        return dao.findFrontList(limit);
    }

    public PageInfo<BookPopularity> findListByLimit(BookPopularity popularity) {
        PageInfo<BookPopularity> pageInfo = PageHelper.startPage(popularity.getPageNum(), popularity.getPageSize())
                .doSelectPageInfo(() -> dao.findListByLimit(popularity));
        return pageInfo;
    }

}